<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Storage;
use DB;

class uploadsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function getIndex()
    {
        return view('shancghuan');
    }

   public  function postFile(Request $request)
   {

       $prefix = "images" . mt_rand(1, 1000);

       $photo = $request->photo;

       $Origname = $photo->getClientOriginalName();

       $name = $prefix . $Origname;

       $src = "/images/avatar/" . $name;

       $realPath = $request->photo->getRealPath();

       Storage::disk('uploads')->put($src, file_get_contents($realPath));

       echo $src;
   }
}
